import { Component } from "react";
import dva from "./utils/dva";
import { Provider } from "react-redux";
import models from "./models";
import Home from "./pages/index";
import "./app.scss";
import { AtMessage } from "taro-ui";
import Taro from "@tarojs/taro";
import QQMapWX from "./libs/qqmap-wx-jssdk";

const dvaApp = dva.createApp({
  models
});

const store = dvaApp.getStore();

const key = "NDGBZ-EDBCX-OZ44M-7HBPD-IESY7-PBBZB";
const qqmapsdk = new QQMapWX({
  key: key
});
class App extends Component {
  componentDidMount() {
    // Taro.getLocation({
    //   type: "gcj02", //返回可以用于 Taro.openLocation的经纬度
    //   success: function(res) {
    //     const latitude = res.latitude;
    //     const longitude = res.longitude;
    //     qqmapsdk.reverseGeocoder({
    //       location: {
    //         latitude: latitude,
    //         longitude: longitude
    //       },
    //       success: res => {
    //         console.log(res);
    //       },
    //       fail: res => {
    //         console.log(res);
    //       }
    //     });
    //   }
    // });
  }

  componentDidShow() {}

  componentDidHide() {}

  componentDidCatchError() {}

  // this.props.children 是将要会渲染的页面
  render() {
    return (
      <Provider store={store}>
        <AtMessage />
        {this.props.children}
      </Provider>
    );
  }
}

export default App;
